package edu.yuhf.web.controller;

import com.github.pagehelper.PageInfo;
import edu.yuhf.service.iface.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("api/v1/product")
public class ProductController {

    @Resource
    ProductService productService;

    @RequestMapping("/list/{pageNum}")
    public ModelAndView productList(@PathVariable String pageNum){
        PageInfo<Map<String,Object>> page =productService.getProductsAllByPage(Integer.valueOf(pageNum),5);
        ModelAndView mav=new ModelAndView("views/product");
        mav.addObject("page",page);
        return mav;
    }
}
